﻿using System;
using NUnit.Framework;
using Coogle.Core;

namespace Coogle.Tests.Core
{
    [TestFixture]
    public class ContainerCodeTests
    {
        [Test]
        public void Equality()
        {
            Assert.That(new ContainerCode("MEDU", 748572, 9), Is.EqualTo(new ContainerCode("MEDU", 748572, 9)));
            Assert.That(new ContainerCode("CTNU", 748572, 9), Is.Not.EqualTo(new ContainerCode("MEDU", 748572, 9)));
            Assert.That(new ContainerCode("MEDU", 123456, 9), Is.Not.EqualTo(new ContainerCode("MEDU", 748572, 9)));
            Assert.That(new ContainerCode("MEDU", 748572, 5), Is.Not.EqualTo(new ContainerCode("MEDU", 748572, 9)));
        }

        [TestCase("MEDU7485729")]
        [TestCase("MEDU 748572 9")]
        [TestCase("MEDU-748572-9")]
        [TestCase("MEDU\\748572\\9")]
        [TestCase("MEDU.748572.9")]
        [TestCase("MEDU/748572/9")]
        [TestCase("medu7485729")]
        public void ParseValidInput(String input)
        {
            Assert.That(ContainerCode.Parse(input), Is.EqualTo(new ContainerCode("MEDU", 748572, 9)));
        }

        [TestCase("MEDU748572")]
        [TestCase("MEDU74857290")]
        [TestCase("MEDU748A729")]
        [TestCase("M6DU7485720")]
        [TestCase("MEDU748572Z")]
        public void ParseInvalidInput(String input)
        {
            Assert.Throws<InvalidContainerCodeException>(() => ContainerCode.Parse(input));
        }
    }
}